CONTENTS | INDEX | PREV | NEXT
putchar
NAME
putchar - output character to stdout (MACRO)
SYNOPSIS
#include <stdio.h>
int r = putchar(c);
FUNCTION
putchar() outputs a character to stdout, returning the output
character unless an error occured. If an error occured then
EOF is returned.
NOTE
refer to the file_pointer manual page for general information
EXAMPLE
/*
* copy stdin to stdout using getchar/putchar. Normally one uses
* fread/fwrite, but I'll save that for the fread manual page.
*
* note that I output the initial message to stderr so it does
* not get stuck into stdout in case the user has redirected
* stdout.
*
* See getc manual page for equivalent example using getc/putc
*/
#include <stdio.h>
main()
{
int c;
fputs("Type a couple of lines, then ^ (EOF)n", stderr);
while ((c = getchar()) != EOF) {
putchar(c);
}
return(0);
}
INPUTS
int c; character to output, 0 to 255
RESULTS
int r; same as c unless error occured in which case EOF.
SEE ALSO
putc, fputc, fread, fwrite, getc, getchar